using System;
using System.Collections.Generic;
using System.Text;
using nDeveloper.Data;
using nDeveloper.BO.Base;
using nDeveloper.BO.Base.Domain;

namespace nDeveloper.UI.Windows.IDE
{
    abstract public class BaseDb : IDisposable
    {
        protected static BaseDataAccess con = new BaseDataAccess(DataBaseConfig.GetConnectionString(), RetornaProviderConfigurado());
        protected static SqlConvert SQLConvert = new SqlConvert(RetornaProviderConfigurado());

        private static Providers RetornaProviderConfigurado()
        {
            Providers prov;

            switch (DataBaseConfig.GetServerType())
            {
                case Constants.vsDataBase.SQLServer2000:
                case Constants.vsDataBase.SQLServer2005:
                    prov = Providers.SqlServer;
                    break;

                case Constants.vsDataBase.Oracle:
                    prov = Providers.Oracle;
                    break;

                case Constants.vsDataBase.MySQL:
                    prov = Providers.MySql;
                    break;

                case Constants.vsDataBase.PostgreSQL:
                    prov = Providers.PostgreSql;
                    break;
                case Constants.vsDataBase.Firebird:
                    prov = Providers.Firebird;
                    break;
                default:
                    prov = Providers.SqlServer;
                    break;
            }

            return prov;
        }

        public virtual void Dispose()
        {
        }
    }
}
